<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>消除游戏</title>
</head>
<body>
  <script>
    function fn(n) {
      return n > 1 ? 2 * (Math.floor(n / 2) + 1 - fn(Math.floor(n / 2))) : 1
    }
    console.log(fn(9))
  </script>
</body>
</html>